<template>
  <div>
    <a-table :columns="columns" :data-source="list">
      <!-- <span class="orderspan" slot="action" slot-scope="text, record, index"> -->
      <span class="orderspan" slot="action" slot-scope="text, record, index">
        <a-popconfirm
          title="确定删除吗？"
          ok-text="是"
          cancel-text="否"
          @confirm="deleteManager(list[index].id)"
        >
          <a href="#">删除</a>
        </a-popconfirm>
        <a-divider type="vertical" />
        <From @upfrom="upfrom" :id="list[index].id" />
      </span>
    </a-table>
  </div>
</template>
<script>
import { listMonk } from "@/api/data";
import From from "@/components/From/index";
// import bus from "@/EventBus.js";
export default {
  name: "Order",
  data() {
    return {
      query: false,
      indexs: "",
      count: 0,
      list,
      params: {
        page: 1,
        perPage: 20
      },
      columns,
      keys: "",
      titleList: [
        {
          value: "寺庙列表",
          type: "video-camera"
        },
        {
          value: "库存动态",
          type: "upload"
        },
        {
          value: "添加商品",
          type: "bar-chart"
        },
        {
          value: "销售商品",
          type: "cloud-o"
        }
      ]
    };
  },
  components: { From },
  mounted() {
    this.getListgoods();
    // bus.$on("list", list => {
    //   this.list = list;
    // });
    // bus.$on("query", query => {
    //   this.query = query;
    // });
  },
  methods: {
    upfrom(event) {
      console.log(event);
      this.list = event;
    },
    confirm(e) {
      console.log(e);
    },
    async getListgoods() {
      const data = await listMonk(this.params);
      const { list } = data;
      this.list = list || [];
      console.log(this.list);
    }
    // async deleteManager(id) {
    //   const data = await deleteGoods(id);
    //   if (data) {
    //     this.$message.success("删除成功");
    //     this.getListgoods();
    //   }
    // }
  }
};

const list = [
  {
    name: "111",
    nation: "hanzu",
    number: "5138...",
    post: "zhiwu"
  },
  {
    name: "222",
    nation: "hanzu",
    number: "5138...",
    post: "zhiwu"
  },
  {
    name: "333",
    nation: "hanzu",
    number: "5138...",
    post: "zhiwu"
  },
  {
    name: "444",
    nation: "hanzu",
    number: "5138...",
    post: "zhiwu"
  },
  {
    name: "555",
    nation: "hanzu",
    number: "5138...",
    post: "zhiwu"
  }
];
const columns = [
  {
    title: "地址",
    dataIndex: "address",
    key: "address",
    scopedSlots: { customRender: "number" },
    customRender: (text, row, index) => {
      // console.log(index);
      return index;
    }
  },
  {
    title: "姓名",
    dataIndex: "name",
    key: "name"
  },
  {
    title: "名族",
    dataIndex: "nation",
    key: "nation",
    ellipsis: true
  },
  {
    title: "身份证号",
    dataIndex: "number",
    key: "number",
    ellipsis: true
  },
  {
    title: "职务",
    dataIndex: "post",
    key: "post",
    ellipsis: true
  },
  {
    title: "备注",
    dataIndex: "remarks",
    key: "remarks",
    ellipsis: true
  },
  {
    title: "创建时间",
    dataIndex: "createTime",
    key: "createTime",
    ellipsis: true
  },
  {
    title: "操作",
    key: "action",
    align: "center",
    dataIndex: "action",
    ellipsis: true,
    scopedSlots: { customRender: "action" }
  }
];
</script>

<style scoped>
.orderspan {
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>